import ajax from './ajax'
import jsonp from 'jsonp'
import { message } from 'antd';
export const reqLogin = () => ajax('https://www.easy-mock.com/mock/5d3ec159963091208a2a22c1/login/login', 'POST')

// 获取天气
export const reqWeather = (city) => {

    return new Promise((resolve, reject) => {
        const url = `http://api.map.baidu.com/telematics/v3/weather?location=${city}&output=json&ak=3p49MVra6urFRGOT9s8UBWr2`
        jsonp(url, {}, (err, data) => {
            // console.log(err, data);
            if (!err && data.status === 'success') {
                const { dayPictureUrl, weather } = data.results[0].weather_data[0]
                resolve({ dayPictureUrl, weather })
            } else {
                // console.log('失败了');
                message.error('获取天气信息失败')
            }
        })
    })
}